package database.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import database.pojo.MachineInfo;
import manager.pay.type.GetMidTradePackageInfo;

public class MidTradePackageInfoDao {
	public GetMidTradePackageInfo selectMidTradePackageByPacketId(int tradeid, Connection conn) throws SQLException{
		String sqlSelect = "select * from trade_package where tradeid = ? ";
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		GetMidTradePackageInfo gPackageInfo = new GetMidTradePackageInfo();
		try{
			pstmt = conn.prepareStatement(sqlSelect);
			pstmt.setInt(1, tradeid);
			rs = pstmt.executeQuery();
			if(rs.next()){
				gPackageInfo.setPrice(rs.getDouble("price")*100);//微信支付单位是分，这周表的单位是元
				gPackageInfo.setTradeName(rs.getString("tradename"));
			}
		}finally{
			if(rs != null){
				rs.close();
			}
			if(pstmt != null){
				pstmt.close();
			}

		}
		return gPackageInfo;
		
	}

}
